<?php
namespace Api\Controller;

use Think\Controller;

/**
 * 文章/资讯
 */
class ArticleController extends CommonController
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 资讯信息
     * @return [type] [description]
     */
    public function index()
    {
        $id = I('post.id', 0, 'intval');

        $article = D('Api/Article', 'Service')->detail($id);

        success($article);
    }

    /**
     * 资讯分类
     * @return [type] [description]
     */
    public function category()
    {
        $category = D('Api/Article', 'Service')->category();

        success($category);
    }

    /**
     * 资讯查找
     * @return [type] [description]
     */
    public function search()
    {
        $data = [
            'category_id' => $category_id = I('post.category_id', 0, 'intval'),
            'page'        => $page = I('post.page', 1, 'intval'),
        ];

        $article = D('Api/Article', 'Service')->search($data);

        success($article);
    }
}
